cmake_minimum_required(VERSION 2.6)
project(pinoteo)

set(QT_MINIMUM_REQUIRED 4.4 CACHE STRING "minimum Qt version")
find_package(Qt4 ${QT_MINIMUM_REQUIRED} REQUIRED)
include( ${QT_USE_FILE} )

set(OUTPUT_DIR bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${OUTPUT_DIR})

add_subdirectory(src)

####################### install #################

set(CPACK_PACKAGE_VERSION "0.5.0")

IF(UNIX AND NOT APPLE)
    FOREACH(LIB QtCore QtXml QtTest QtGui QtNetwork QtScript)
        INSTALL(FILES
            "${QT_LIBRARY_DIR}/lib${LIB}.so.${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}"
            RENAME "lib${LIB}.so.${QT_VERSION_MAJOR}"
            DESTINATION ${OUTPUT_DIR}
        )
    ENDFOREACH(LIB)
ENDIF(UNIX AND NOT APPLE)

IF(UNIX AND APPLE)
    FOREACH(LIB QtCore QtXml QtTest QtGui QtNetwork QtScript)
        INSTALL(FILES
            "${QT_LIBRARY_DIR}/lib${LIB}.${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.dylib"
            RENAME "lib${LIB}.${QT_VERSION_MAJOR}.dylib"
            DESTINATION ${OUTPUT_DIR}
        )
    ENDFOREACH(LIB)
ENDIF(UNIX AND APPLE)

IF(WIN32)
	FOREACH(LIB QtCore QtXml QtTest QtGui QtNetwork QtScript)
	    INSTALL(FILES
	        "${QT_LIBRARY_DIR}/${LIB}${QT_VERSION_MAJOR}.dll"
	        DESTINATION ${OUTPUT_DIR}
 		ENDFOREACH(LIB)
    )
ENDIF(WIN32)

include(CPack)